/*
* wid = fiecare fereastra are un id(unicat)
* par = parametrii
* tip='GET' sau 'POST'
* nview('My stats','khon.callback.php','600','500','1','GET','p=1&t=2');
*/

function nview(title,pagina,width,height,wid,tip,par){
    // vars
    var closemleft = width - 20;
    var texth = height - 36;
    if($("#nview"+wid).length>0){alert("Nview already opened: nview id "+ wid);return;}
    
    var k="<div id='nview"+wid+"' class='nview' style='width:"+width+"px; height:"+height+"px;'>";
        k+="<div class='closebtn' style='position:absolute; margin-left:"+closemleft+"px; margin-top:5px;' onclick='nclose(\""+wid+"\");'></div><div class='ntitle'>"+title+"</div>";
        k+="<div class='ntext' style='height:"+texth+"px;'>";

    $.ajax({
    type: tip,
    url: pagina,
    data: par,
    //beforeSend:function(xhr){$(rez).html("<img src='Imagini/loader.png' />");},
    error: function(err){alert("Connection error - AJAX[21]");},
    success: function(msg){
           k+=msg+"</div></div>";
           $("#nspace").append(k);
           $("#nview"+wid).show("slow");
           $(".ntitle").mouseover(function(){$(".ntitle").css('cursor', 'move');$('#nview'+wid).draggable({ disabled: false, opacity: 0.35, delay: 100, cursor: 'move', containment: '#main', cancel: '#taskbar' });}).mouseout(function(){$('#nview'+wid).draggable({ disabled: true });});
    }
    });
    
    
}
//Close window id
function nclose(wid){$("#nview"+wid).remove();}
